﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Table
{
    class Program
    {
        static void Main(string[] args)
        {
            //Hashtable类：哈希表

            Hashtable ht = new Hashtable();
            ht.Add("001", "aaa");
            ht.Add("002", "bbb");
            ht.Add("003", "ccc");
            ht.Add("004", "ddd");
            ht.Add("005", "eee");
            ht.Add("006", "fff");
            ht.Add("007", "ggg");
            
            if (ht.ContainsValue("aaa"))
            {
                Console.WriteLine("提取aaa");
            }
            else
            {
                //添加008和www
                ht.Add("008", "www");
            }
            //获取键的集合
             ICollection key = ht.Keys;
            foreach(string k in key)
            {
                Console.WriteLine(k+":"+ht[k]);
            }
           
            
          /*  Hashtable str = new Hashtable();
            str.Add(1, "历史");
            str.Add(2, "地理");
            str.Add(3, "化学");
            Console.WriteLine("请输入图书编号：");
            int id = int.Parse(Console.ReadLine());
            bool flag = str.ContainsKey(id);
            if (flag)
            {
                Console.WriteLine("你查找的图书名称为：{0}",str[id ].ToString());
            }
            else
            {
                Console.WriteLine("你找的图书信息不在！");
            }
            Console.WriteLine("所有图书信息如下：");
            foreach(DictionaryEntry  d in str)
            {
                int key = (int)d.Key;
                string value = d.Value.ToString();
                Console.WriteLine("图书编号：{0}，图书名称：{1}",key,value);
            }*/
        }
    }
}
